A first lien note is similar to a mortgage: it's a promise that if you don't pay the money, your creditor can take the assets that the lien applies to. So, yes, if a company is close to bankruptcy, a first lien note can be appropriate: it gives the lender some assurance that they will get paid or get the property, even if the company files bankruptcy.
More generally, a secured note is attached to some sort of underlying security interest -- if the borrower doesn't pay, the lender can get the property instead. The property can be anything that both parties agree is valuable. When it's real estate, the security interest is referred to as a mortgage; when it's anything else, it's a lien.
There can be multiple security interests in the same property. So you can have a mortgage on your property, and you can have a second mortgage. The second mortgage comes after the first; if you don't pay, the holder of the first mortgage gets to sell the property and take their money from the proceeds. The holder of the second mortgage gets paid from whatever is left over after that.
A first lien note is like that first mortgage: there's nobody in line ahead of the holder of the first lien note. So they've got the full value of the collateral backing up the payments that are owed to them.
To answer the actual question: if everyone knows that a company is close to bankruptcy, the company will have a hard time getting unsecured financing, because lenders won't have any special priority in bankruptcy. To make lending more attractive, a company can issue first lien notes, which, being secured by the underlying property, are much less risky. Even in bankruptcy, the lender gets the underlying property if the loan isn't repaid.