The novel physics of twisted bilayer graphene has motivated extensive studies of magic-angle flat bands hosted by moiré structures in electronic, photonic, and acoustic systems. On the other hand, bound states in the continuum (BICs) have also attracted great attention in recent years because of their potential applications in the field of designing superior optical devices. Here, we combine these two independent concepts to construct a new optical state in a twisted bilayer photonic crystal slab, which is called as moiré quasi-BIC, and numerically demonstrate that such an exotic optical state possesses dual characteristics of moiré flat bands and quasi-BICs. To illustrate the mechanism for the formation of moiré flat bands, we develop an effective model at the center of the Brillouin zone and show that moiré flat bands could be fulfilled by balancing the interlayer coupling strength and the twist angle around the band edge above the light line. Moreover, by decreasing the twist angle of moiré photonic crystal slabs with flat bands, it is shown that the moiré flat-band mode at the Brillouin center gradually approaches a perfect BIC, where the total radiation loss from all diffraction channels is significantly suppressed. To clarify the advantage of moiré quasi-BICs, enhanced second-harmonic generation (SHG) is numerically proven with a wide-angle optical source. The efficiency of SHG assisted by designed moiré quasi-BICs can be greatly improved compared with that based on dispersive quasi-BICs with similar quality factors.