Although truth is in most cases a defence in a libel case, it is often difficult and lengthy (thus expensive) to prove in court. If your published book tells a true story about events that occurred, the first step to protect yourself is by changing the names of people or organisations in the book. However, simply changing a name from "Jim" to "David" is often not enough. If a person or others can recognise themselves from the situation, places or events even if their name is changed, you can still be sued for libel. Changing the location also helps to distance the story so that it is unrecognisable to real people. You can use a pen name to further distance any recognisable trail back to you or, most importantly, the real person, in order to avoid trouble.
For instance, imagine an individual reader knows you, the author in real life. If you make claims about your husband's doctor, even if you change your husband's name and the doctor's name, but you keep your real name, it is pretty clear to someone involved who you are talking about in reality. By using a pen name and changing the name of people in the book, this will help to further remove the specifics and protect you against any libel claims.
Voicing an opinion is not libellous; however, be careful that you are not actually making an accusatory statement. Even if you say "in my opinion" before a statement, that does not automatically make the statement an opinion if you are speculating or asserting something about someone.
Do not make the following statements or claims, as they are clear grounds for a libel case: Falsely accusing someone of a crime, or having been charged, indicted or convicted of a crime; falsely identifying someone as the carrier of an infectious or loathsome disease; falsely charging someone or an organisation with a claim that discredits or disqualifies a business, office or trade and lowers their profitability; and falsely accusing someone as being impotent.
Seriously consider if you are self-publishing a book that makes statements or reveals information that could damage someone, and consult a legal advisor if you are concerned.