I was trying to google this when I got a Microsoft Keyboard. It’s such a convenient bluetooth keyboard to carry around with my tablet. I came across this article http://www.guidingtech.com/19202/hide-on-screen-keyboard-android-external/ but it involved 3rd party apps and a complex process. I discovered though that at least with Android 5.1, it’s now a built in function to disable the onscreen keyboard from showing up when you have an external keyboard attached to the tablet.
You’ll find this under Language & Input -> Current Keyboard -> Turn off the Hardware switch
They really need to improve the phrasing of that setting….