What are the advantages and disadvantages of courtship behaviour in animals?
They are energetically "costly" for the organism, but if they help attract a genetically "good" mate they are worth it.
Courtship displays are common in many animals species and they are highly unique to each species and have evolved likely over thousands or millions of years.
Most commonly, courtship displays are done by males to attract the attention of females (though there are many exceptions). These can include behavioural displays (like male deers fighting for dominance and the opportunity to mate with all the females), but can also include phenotypical features on their bodies that enhance their appeal to females (e.g. large colourful tail of the male peacock). This is part of what is called "sexual selection".
The downside is that these ornamentation and behaviours not only attracts females, but it might also attract a predator to eat you! Also, carrying around a big heavy tail (like the peacock) makes it harder for a male to escape danger if attacked.
The upside is that females will often choose the male with the best courtship behaviour and so the male will pass on his genes and his family lineage will go on, while the losers line will die out. The risk is worth it!