Market failure and the purpose of regulation

  What is market failure and what is the purpose of regulation?