In package/class files and in your preamble, paragraph breaks do not have any special meaning so empty lines are innocuous. Use them generously to structure your code.
Important caveat: even in the preamble, when you define a macro the newlines inside the definition will be interpreted in the context of their expansion so if you are going to use them in the body, the rules below apply.
When catcodes are changed (for example by use of
\obeylines) there are no general rules and you need to examine the active character's definitions in that context.
In the body of the document some care should be taken.
As mentioned in the comments, an empty line, in the body, is a paragraph break.
You should use them to mark the end of paragraphs.
Note however, that consecutive multiple empty lines constitute a single paragraph break and thus they can be used to separate portions of code without inserting extra space apart from that single break.
Some commands, such as sectioning commands, already take care of spacing and insert paragraphs breaks when necessary before the section, so empty lines preceding them will not harm.
Other commands/environments like equations, itemizes or tables, instead are sensitive to the presence of paragraph breaks around them and you should put some care in deciding whether you want that break or not.
In case you don't but want to keep some vertical space in code, you can always escape the line with
In math mode white space is generally discarded but empty line still generate paragraph breaks which are not allowed, so you should always escape them.
There are similar issues within some environments as tabular, where paragraph breaks are not allowed without extra care (e.g. by using