Betta fish may sleep by the filter for a variety of reasons. One possible reason is that the filter creates a gentle flow of water that the betta fish finds soothing and comfortable. Additionally, the filter may provide a more oxygen-rich spot for the betta fish to sleep in.