It depends on which type of beta (a measure of risk) you mean. Debt affects a company's levered beta in that increasing the total amount of a company's debt will increase the value of its levered beta, and vice versa. Debt does not affect a company's unlevered beta, which by its nature does not take debt or its effects into account.
Since both unlevered beta and levered beta measure the volatility of a stock in relation to movements in the overall market, a company's levered beta shows that the more debt a company has, the more volatile it will be in relation to market movements.
The equation for a company's levered beta is as follows:
Beta levered=Beta unlevered∗(1+Equity(1−tax rate)∗Debt)
If a company increases its debt to the point where its levered beta is greater than 1, the company's stock is more volatile than the market. If a company decreases its debt to the point where its levered beta is less than 1, the company's stock is less volatile than the market. If a company has no debt, its unlevered beta and levered beta would be equal.
While a company's levered beta shows the amount of volatility that can be associated with its capital structure, it is ineffective when comparing the volatility of two different companies. Since capital structures vary across different companies, it doesn't make sense to compare the levered betas of two companies.
Use the unlevered beta to compare the betas of two different companies. If you want to understand the volatility of a specific company, including its capital structure, use the levered beta.