An excellent time line of Obama’s Shadow Government and his surveillance of the Trump campaign here.
In summary: the Obama administration sought, and eventually obtained, authorization to eavesdrop on the Trump campaign; continued monitoring the Trump team even when no evidence of wrongdoing was found; then relaxed the NSA rules to allow evidence to be shared widely within the government, virtually ensuring that the information, including the conversations of private citizens, would be leaked to the media.