A margin account is effectively debt that is secured against your investments. In general, debt is the cheapest when it is secured against your assets [ie: the lender has the legal right to liquidate your assets to cover off your debt, if you are unable to make payments].
For many people, the most common form of secured debt is a mortgage secured against your house. There are a lot of legal protections for lenders who lend money for home purchases across most jurisdictions, and this allows the interest rates offered to typically be the lowest rates available to the average consumer. Remember that this cheap interest rate does come at a cost - the risk of your residence if you fail to make mortgage payments! [Side note: student loans being cheap is typically related to the fact that they are not dischargeable on bankruptcy, so again the protections offered to lenders can make for attractive rates, with an often-overlooked risk to the borrower!].
In the event that you have unsecured debt [like a personal loan, or a credit card], it may be possible to consolidate that debt with a payment plan and an assigned lower rate. Even without having security available, there can be benefits in this consolidation [seek advice on that matter from an expert if you are in that position]. To the extent you can attach security to that consolidated debt, your interest rate will drop even lower. For example, it may be beneficial to increase the debt secured against your house, either as a 2nd mortgage or a Home Equity Line Of Credit [again - at the increased risk of putting your house in potential future danger of liquidation].
Now to your question on using a margin account for this purpose: To the extent that other forms of security are not available to you, you may be able to effectively secure your investments against your borrowings, and achieve a lower rate than what would be possible with a personal loan. Whether this is wise would depend on a lot of factors. Keep in mind that a margin account will require you to keep a certain amount of investments with the broker [which is their security], so this isn't something that would work purely as a loan.
As an example of how this might work: if you had, say, $50k with a broker, you might be able to open a margin account, borrow $20k, and pay off some other outstanding debt you had. Your broker still maintains the right to liquidate your assets to cover off this $20k in borrowed funds under various circumstances [like, your $50k in assets drops significantly in value, so they become less certain that they will be able to cover themselves off against losses if your assets drop further].